<?php
/**
 * Created by PhpStorm.
 * User: 87976
 * Date: 2018/1/18
 * Time: 15:00
 */

namespace App\Services\HomeTemplates;

use App\Abstracts\TemplateAbstract;
use App\Repositories\HomeTemplates\HomeFontRepository;

class HomeTextService extends TemplateAbstract
{

    protected $homeFontRepository;

    public function __construct(HomeFontRepository $homeFontRepository)
    {
        $this->homeFontRepository = $homeFontRepository;
    }

    public function handle(array $data)
    {
        $font = $this->findFontDataById($data['id']);

        $data['data'] = $font;

        return $data;
    }

    protected function checkFontType(int $type)
    {

    }

    protected function findFontDataById(int $id)
    {
        $fonts = $this->homeFontRepository->findWhere([
            'stencil_id' => $id,
        ]);

        if ($fonts->isEmpty()) {
            return [];
        }

        return $fonts->first()->toArray();
    }
}